package tempData.bulider;

public class person {
    private String name;
    private int age;
    //插件Inner Builder生成 变种 Builder 模式代码
    private person(Builder builder) {
        name = builder.name;
        age = builder.age;
    }

    public static final class Builder {
        private String name;
        private int age;

        public Builder() {
        }

        public Builder name(String val) {
            name = val;
            return this;
        }

        public Builder age(int val) {
            age = val;
            return this;
        }

        public person build() {
            return new person(this);
        }
    }

    @Override
    public String toString() {
        return "person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
